<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', function () {
    return view('welcome');
});
//基础路由请求
Route::get('basic', function () {
    return 'welcome';
});

Route::post('basic1', function () {
    return 'welcome1';
});
//多请求路由
Route::match(['post','get'],'multy1',function(){
    return 'welcome21';
});

Route::any('multy2', function () {
    return 'welcome22';
});

//路由参数-基本参数
/*Route::get('user/{id}', function ($id) {
    return 'User-id-' . $i
//路由参数-可选参数（增加问号）添加默认值
/*Route::get('user/{id?}', function ($id = null) {
    return 'User-id-' . $id;
});*/

//路由参数-添加参数限制条件
Route::get('user/{id}/{name?}', function ($id,$name = null) {
    return 'User-id-' . $id . '-name-' . $name;
})->where(['id'=>'[0-9]+','name'=>'[A-Za-z]+']);


//路由别名,路由变更时，例如member-center改为center，模板中不需要更改，因为使用route函数生成的路由会自动更新
//Route::get('user/member-center',['as'=>'center',function(){
//    return route('center');
//}]);

//路由群组，添加群组前缀
Route::group(['prefix'=>'member'],function(){
    //访问路径为http://localhost/laraval/public/member/user/member-center
    Route::get('user/member-center',['as'=>'center',function(){
        return route('center');
    }]);

    //访问路径为http://localhost/laraval/public/member/user/member-center
    Route::any('multy2', function () {
        return 'member-welcome22';
    });
});

//路由中输出视图
Route::get('view', function () {
    return view('welcome');
});

//路由绑定，把路由与控制器对应函数进行绑定
//Route::get('member/info','MemberController@info');

//路由绑定，添加别名
Route::get('member/info11',[
    'uses'=>'MemberController@info',
    'as'=>'memberinfo'
]);

//参数传递
//Route::get('member/{id}','MemberController@info')->where(['id'=>'[0-9]+']);

Route::get('member','MemberController@info');

//数据操作
Route::get('dbbase',[
    'uses'=>'StudentController@dbbase'
]);

Route::get('query_add',['uses'=>'StudentController@query_add']);
Route::get('query_edit',['uses'=>'StudentController@query_edit']);
Route::get('query_del',['uses'=>'StudentController@query_del']);
Route::get('query_query',['uses'=>'StudentController@query_query']);
Route::get('query_juhe',['uses'=>'StudentController@query_juhe']);


Route::get('orm',['uses'=>'StudentController@orm']);
Route::get('query_orm',['uses'=>'StudentController@query_orm']);

Route::get('orm_add',['uses'=>'StudentController@orm_add']);
Route::get('orm_edit',['uses'=>'StudentController@orm_edit']);
Route::get('orm_del',['uses'=>'StudentController@orm_del']);



Route::get('section',['uses'=>'StudentController@section']);


Route::get('url',['as'=>'asurl','uses'=>'StudentController@url']);


Route::get('student/request',['as'=>'request','uses'=>'StudentController@request']);


//使用session之前需要启动session，由web函数完成
//使用中间件
Route::group(['middleware' => ['web']],function(){
    Route::get('session1',['uses'=>'StudentController@session1']);
    Route::get('session2',['uses'=>'StudentController@session2']);
    Route::get('response',['uses'=>'StudentController@response']);
});

Route::get('pro_activity',['uses'=>'StudentController@pro_activity']);

Route::group(['middleware' => ['activity']],function(){
    Route::get('ing1_activity',['uses'=>'StudentController@ing1_activity']);
    Route::get('ing2_activity',['uses'=>'StudentController@ing2_activity']);
});

Route::get('student/form',['uses'=>'StudentController@form']);
Route::get('student/form_detail/{id}',['uses'=>'StudentController@form_detail']);
Route::get('student/form_edit/{id}',['uses'=>'StudentController@form_edit']);
Route::any('student/form_save/{id}',['uses'=>'StudentController@form_save']);
Route::any('student/form_add',['uses'=>'StudentController@form_add']);
Route::any('student/form_add_save',['uses'=>'StudentController@form_add_save']);
Route::any('student/form_del/{id}',['uses'=>'StudentController@form_del']);

Route::get('student/jpush',['uses'=>'StudentController@jpush']);



